<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改房源信息</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<div class="wrapper" style="width: 900px;margin-top: 40px">
    <fieldset class="layui-elem-field layui-field-title">
        <legend style="font-size: 26px">修改我发布的房源信息</legend>
    </fieldset>
    <form id="updateHouse" class="layui-form">
     <input type="hidden" th:value="${house.getHouseId()}" name="houseId">
        <div class="layui-form-item">
            <label class="layui-form-label">房源标题</label>
            <div class="layui-input-block">
                <textarea name="houseDesc" th:text="${house.getHouseDesc()}" class="layui-textarea" required lay-verify="required"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">出租方式</label>
            <div class="layui-input-block">
                <select name="houseType" lay-verify="required">
                    <option value=""></option>
                    <option value="整租" th:if="${house.getHouseType()=='整租'}" selected>整租</option>
                    <option value="合租" th:if="${house.getHouseType()=='合租'}" selected>合租</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
        <label class="layui-form-label">房间大小</label>
        <div class="layui-input-block">
            <input type="text" name="houseArea" required lay-verify="required" placeholder=""
                   autocomplete="off" th:value="${house.getHouseArea()}" class="layui-input">
        </div>
    </div>
        <div class="layui-form-item">
            <label class="layui-form-label">出租价格</label>
            <div class="layui-input-block">
                <input type="text" name="housePrice" required lay-verify="required" placeholder=""
                       autocomplete="off" th:value="${house.getHousePrice()}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">出租地址</label>
            <div class="layui-input-block">
                <input type="text" name="houseAddress" required lay-verify="required" placeholder=""
                       autocomplete="off" th:value="${house.getHouseAddress()}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="houseTel" required lay-verify="required|phone" placeholder=""
                       autocomplete="off" th:value="${house.getHouseTel()}" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="updateHouse" id="updateHouse-btn">立即修改</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['element','form','layer'],function () {
        var element = layui.element,
            form = layui.form ,
            layer = layui.layer,
            $ = layui.jquery;

        form.on("submit(updateHouse)",function(){
        	$.post("/rent/house/updateHouse",$("#updateHouse").serialize(),function(res){
               $("#updateHouse")[0].reset();
        		if(res==="OK"){
        			 layer.msg("修改成功！",{time:1000,end:function(){window.history.back(-1);}});
        		}
        	})
        	return false;
        })
    });


</script>
</body>
</html>
